//
//  RunCardRecordDetailVC.m
//  MRBang
//
//  Created by 铅笔 on 15/12/16.
//  Copyright © 2015年 杭州易网新科技. All rights reserved.
//
//办卡纪录 详情页面 VC

#import "RunCardRecordDetailVC.h"
#import "ApplyRecordAndDoCarRecordView.h"

@interface RunCardRecordDetailVC ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *tableView;
//@property (nonatomic,strong) NSMutableArray *mutableArray_data;//存放所有数据

@property (nonatomic,strong) UIView *view_topThreLabel;//头部三个label


@end

@implementation RunCardRecordDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];

self.title = @"办卡纪录详情";

//创建子视图
[self initWithAllSubviews];

}

#pragma mark ---- 创建子视图
- (void) initWithAllSubviews
{
    
    [self initWithTopThreeLabel];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,self.view_topThreLabel.frame.size.height+self.view_topThreLabel.frame.origin.y, kScreenWidth, kScreenHeight-99)];
    [self.view addSubview:self.tableView];
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    
    self.tableView.showsVerticalScrollIndicator = NO;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
}

//申请银行 申请日期 状态
- (void) initWithTopThreeLabel
{
    self.view_topThreLabel = [[UIView alloc] initWithFrame:CGRectMake(0,64, kScreenWidth, 35)];
    [self.view addSubview:self.view_topThreLabel];
    
    
    NSArray *array_titleLabel = @[@"申请银行",@"申请日期",@"状态"];
    
    for (int i=0; i<3; i++) {
        
        UILabel *label_titleText = [[UILabel alloc] init];
        [self.view_topThreLabel addSubview:label_titleText];
        label_titleText.textColor = RXDColor(102, 102, 102);
        
        CGFloat labelX = kScreenWidth/3;
        label_titleText.frame = CGRectMake(labelX*i,5, labelX, 30);
        label_titleText.text = array_titleLabel[i];
        label_titleText.textAlignment = NSTextAlignmentCenter;
        label_titleText.font = [UIFont systemFontOfSize:14];
    }
    
    //横线
    UIView *view_line  = [[UIView alloc] initWithFrame:CGRectMake(0,34, kScreenWidth, 1.0)];
    [self.view_topThreLabel addSubview:view_line];
    view_line.backgroundColor = [UIColor colorWithRed:249.0/255.0 green:249.0/255.0 blue:249.0/255.0 alpha:1.0];
}

#pragma mark --- UITableViewDataSource
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"cellRunCardRecordDetail";
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row==0) {
        
        ApplyRecordAndDoCarRecordView *applyView = [[ApplyRecordAndDoCarRecordView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 160)];
        [cell.contentView addSubview:applyView];
        
    }
    else
    {
        NSArray *array_text = @[@"申请人资料:",@"姓名",@"身份证号码",@"婚姻状态",@"住宅情况"];
#warning 暂时
        NSArray *array_textRight = @[@"钱多多",@"34222519931116052x",@"已婚",@"有购房"];
        //title
        UILabel *label_title = [[UILabel alloc] initWithFrame:CGRectMake(20,0,100, 30)];
        [cell.contentView addSubview:label_title];
        label_title.text = array_text[indexPath.row-1];
        label_title.textColor = RXDColor(170, 170, 170);
        label_title.font = [UIFont systemFontOfSize:14];
        
        //label Right
        UILabel *label_right = [[UILabel alloc] initWithFrame:CGRectMake(label_title.frame.size.width+label_title.frame.origin.x+5,0,kScreenWidth-60-label_title.frame.size.width, 30)];
        [cell.contentView addSubview:label_right];
        label_right.text = array_text[indexPath.row-1];
        label_right.textColor = RXDColor(170, 170, 170);
        label_right.font = [UIFont systemFontOfSize:14];
        
        if (indexPath.row==1) {
            label_right.text = @"";
        }
        else
        {
            label_right.text = array_textRight[indexPath.row-2];
        }
        if (indexPath.row==3 || indexPath.row==4 ||indexPath.row==5) {
            UIButton *button_lookMess = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth-60, 5, 55, 25)];
            [cell.contentView addSubview:button_lookMess];
            [button_lookMess setTitle:@"查看证件" forState:UIControlStateNormal];
            [button_lookMess setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [button_lookMess.titleLabel setFont:[UIFont systemFontOfSize:13]];
            button_lookMess.layer.cornerRadius = 3.0;
            button_lookMess.clipsToBounds = YES;
            button_lookMess.layer.borderColor = [UIColor redColor].CGColor;
            button_lookMess.layer.borderWidth = 1.0;
        }

    }
    return cell;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 160;
    }
    else
    {
        return 40;
    }
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}

@end
